<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateTariffTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('tariff', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->bigInteger('company_id')->index()->comment('公司ID');
            $table->enum('type', [1, 2])->default(1)->index()->comment('类型：1-乘客，2-司机');
            $table->bigInteger('service_type_id')->comment('业务类型ID');
            $table->string('name',100)->comment('规则名称');
            $table->timestamp('open_time')->comment('启用时间');
            $table->json('basics')->comment('基础费');
            $table->json('mileage')->comment('里程费');
            $table->json('duration')->comment('时长费');
            $table->json('distance')->nullable()->comment('远途费');
            $table->json('waiting_timeout')->comment('超时等待');
            $table->json('other_settings')->nullable()->comment('其他设置');
            $table->bigInteger('creator_id')->comment('创建者ID');
            $table->bigInteger('modifier_id')->nullable()->comment('修改人ID');
            $table->timestamps();
            $table->softDeletes();
        });
        DB::statement("ALTER TABLE `tariff` comment '资费表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('tariff');
    }
}
